home *** CD-ROM | disk | FTP | other *** search
/ PC Play 129 / pc play 129.iso / Demo / man2 / man2.exe / data / scripts / destroyer_scripts.lua < prev    next >
Encoding:
Text File  |  2006-08-31  |  6.3 KB  |  176 lines

  1.  
  2. function units_destroyer_setup()
  3.     units_setup_sea(5,false,true,ENET_EFFECT_GEOMETRY_TORPEDOSHIPSHADOW)
  4. end
  5.  
  6. function units_destroyer_resetup()
  7.     units_setup_sea(5,false,false,ENET_EFFECT_GEOMETRY_TORPEDOSHIPSHADOW)
  8. end
  9.  
  10. function units_destroyer_select()
  11.     units_select(17,2)
  12. end
  13.  
  14. function units_destroyer_unselect()
  15.     units_unselect()
  16. end
  17.  
  18. function units_destroyer_selectenemy()
  19.     uniGetExecutor():addSimpleEffect(ENET_EFFECT_SELECTEDGEOMETRY_ENEMY)
  20. end
  21.  
  22. function units_destroyer_damaged()
  23.     uniGetExecutor():applyDamage(uniGetLife())
  24. end
  25.  
  26. function units_destroyer_highlight()
  27.     uniGetExecutor():addEffectWithRadius(ENET_EFFECT_GEOMETRY_HIGHLIGHT,15)
  28. end
  29.  
  30. function units_destroyer_explode()
  31.     units_explode_water4()
  32. end
  33.  
  34. function units_destroyer_move()
  35.     local unit = uniGetExecutor()
  36.     local sound = unit:play3DSound("destroyer_move.wav",1)
  37.     local steps = unit:addSimpleEffect(ENET_EFFECT_EFFECTEMITTER_SHIP_WATERTRAY)
  38.     waitDeath(unit:addRotationEffect(ENET_EFFECT_ROTATE_UNIT,MATH_PI * 0.7))
  39.     waitDeath(unit:addMoveEffect(ENET_EFFECT_MOVE_LINEAR,80))
  40.     steps:suspendedDestroy(2.0)
  41.     sound:destroy()
  42. end
  43.  
  44. function units_destroyer_fire1()
  45.     local unit = uniGetExecutor()
  46.     local gt = unit:getBone(ENBT_GUNTOWER)
  47.     local sound = gt:play3DSound("destroyer_guntower_rotate.wav",1)
  48.     waitDeath(gt:addRotationEffect(ENET_EFFECT_ROTATE_GUNTOWERTOTARGET,MATH_PI,uniGetTarget()))
  49.     sound:stopSound()
  50.     pause(0.3)
  51.     local firespot = gt:getBone(ENBT_FIRE1)
  52.     local shot = firespot:addBulletEffect(ENET_EFFECT_BULLET_REDLASERBOLT)
  53.     shot:executeCommand(ENC_FIRE1)
  54.     unit:addFireArrow()
  55. end
  56.  
  57. function units_destroyer_fire2()
  58.     local unit = uniGetExecutor()
  59.     uniSetLife(uniGetLife() / 2.0)
  60.     waitDeath(unit:addRotationEffect(ENET_EFFECT_ROTATE_UNIT,MATH_PI * 0.7,uniGetTarget()))
  61.     local gn = unit:getBone(ENBT_GUNNEST)
  62.     unit:addAnimationToQueue(ENAT_PREPAREFORFIRE1,1)
  63.     unit:addAnimationToQueue(ENAT_FIREPOSITION1,MATH_INFINITY)
  64.     unit:addAnimationToQueue(ENAT_AFTERFIRE1,1)
  65.     pause(0.3)
  66.     gn:getBone(ENBT_FIRE2,0):addBulletEffect(ENET_EFFECT_BULLET_TORPEDO):executeCommand(ENC_FIRE1)
  67.     pause(1.0)
  68.     gn:getBone(ENBT_FIRE2,1):addBulletEffect(ENET_EFFECT_BULLET_TORPEDO):executeCommand(ENC_FIRE1)
  69.     pause(1.0)
  70.     unit:setCurrentAnimationRepeatCount(0)
  71.     unit:addFireArrow()
  72. end
  73.  
  74. registerCommand(ENSCRIPTSET_TORPEDOSHIP,ENC_MOVE,"units_destroyer_move")
  75. registerCommand(ENSCRIPTSET_TORPEDOSHIP,ENC_FIRE1,"units_destroyer_fire1")
  76. registerCommand(ENSCRIPTSET_TORPEDOSHIP,ENC_FIRE2,"units_destroyer_fire2")
  77. registerCommand(ENSCRIPTSET_TORPEDOSHIP,ENC_SELECT,"units_destroyer_select")
  78. registerCommand(ENSCRIPTSET_TORPEDOSHIP,ENC_SELECTENEMY,"units_destroyer_selectenemy")
  79. registerCommand(ENSCRIPTSET_TORPEDOSHIP,ENC_UNSELECT,"units_destroyer_unselect")
  80. registerCommand(ENSCRIPTSET_TORPEDOSHIP,ENC_SETUP,"units_destroyer_setup")
  81. registerCommand(ENSCRIPTSET_TORPEDOSHIP,ENC_RESETUP,"units_destroyer_resetup")
  82. registerCommand(ENSCRIPTSET_TORPEDOSHIP,ENC_DAMAGED,"units_destroyer_damaged")
  83. registerCommand(ENSCRIPTSET_TORPEDOSHIP,ENC_EXPLODE,"units_destroyer_explode")
  84. registerCommand(ENSCRIPTSET_TORPEDOSHIP,ENC_HIGHLIGHT,"units_destroyer_highlight")
  85.  
  86. -- make description of unit
  87. desc = getEffectDescriptionP(ENET_UNIT_TORPEDOSHIP)
  88. desc.ClassID = ENCLASS_MESHINSTANCE
  89. desc.EffectClassType = ENECT_GEOMETRY
  90. desc.FileName = "torpedoship.rmd"
  91. desc.ScriptSet = ENSCRIPTSET_TORPEDOSHIP
  92. desc.MoveType = ENMOVE_SWIM
  93. desc.RenderType = ENRENDERTYPE_GEOMETRY
  94. desc.Material = ENMAT_RIGIDSKINNEDMESH
  95. desc.MaterialColors = units_materialcolors_human
  96.  
  97. -- shadow
  98. desc = getEffectDescriptionP(ENET_EFFECT_GEOMETRY_TORPEDOSHIPSHADOW)
  99. desc.ClassID = ENCLASS_MESHINSTANCE
  100. desc.EffectClassType = ENECT_GEOMETRY
  101. desc.FileName = "torpedoship_shadow.rmd"
  102. desc.RenderType = ENRENDERTYPE_SHADOW
  103. desc.Material = ENMAT_SHADOW
  104. desc.MaterialColors = units_materialcolors_shadow
  105.  
  106. -- register new unit to logic
  107. unitDesc = logic_getUnitDescP(8)
  108. unitDesc.group = 1
  109. unitDesc.order = 0
  110. unitDesc.unit_res_id = ENET_UNIT_TORPEDOSHIP
  111. unitDesc.unit_icon_id = "Torpedoship_h_small_normal.dds"
  112. unitDesc.active_id = "Torpedoship_h_small_active.dds"
  113. unitDesc.pressed_id = "Torpedoship_h_small_pressed.dds"
  114. unitDesc.big_icon_id = "Torpedoship_h_big_normal.dds"
  115. unitDesc.small_icon_id = "Torpedoship_u_stats.dds"
  116. unitDesc.HP = 5
  117. unitDesc.MP = 30
  118. unitDesc.WR = 2
  119. unitDesc.min_WR = 1
  120. unitDesc.WD = 1
  121. unitDesc.WR2 = 0
  122. unitDesc.min_WR2 = 0
  123. unitDesc.WD2 = 0
  124. unitDesc.ability = 3
  125. unitDesc.transport = 0
  126. unitDesc.value = 2
  127. unitDesc.race = 0
  128. unitDesc.fire_pause = 0.8
  129. unitDesc.move_pause = 1.0
  130. unitDesc.unit_info_scale = 0.04
  131. unitDesc.scn_name = "DESTROYER"
  132.  
  133. ------------------------------------------------------------------------------------------------------
  134. ------------------------ effects related to unit------------------------------------------------------
  135. ------------------------------------------------------------------------------------------------------
  136.  
  137. function bullets_torpedo_fire()
  138.     local bullet = uniGetExecutor()
  139.     bullet:setTransformOwner()
  140.     local sound = bullet:play3DSound("destroyer_torpedo_fly.wav",1)
  141.     local track = bullet:addSimpleEffect(ENET_EFFECT_PS_TORPEDO_WATERTRAY)
  142.     waitDeath(bullet:forwardFly(uniGetTarget(),100))
  143.     sound:destroy()
  144.     track:suspendedDestroy(1.0)
  145.     bullet:play3DSound("destroyer_torpedo_explode.wav",0):destroy()
  146.     bullet:setVisibility(false,true)
  147.     bullet:addSimpleEffect(ENET_EFFECT_LIGHT_ROCKETEXPLODE):delayedDestroy(2.0)
  148.     bullet:addSimpleEffect(ENET_EFFECT_PS_TORPEDOHIT):suspendedDestroy(2.0)
  149.     uniGetTarget():executeCommand(ENC_DAMAGED)
  150.     pause(2.0)
  151.     bullet:destroy()
  152. end
  153.  
  154. registerCommand(ENSCRIPTSET_BULLET_TORPEDO,ENC_FIRE1,"bullets_torpedo_fire")
  155.  
  156.  
  157.  
  158. function bullets_redlaserbolt_fire()
  159.     local bullet = uniGetExecutor()
  160.     bullet:setTransformOwner()
  161.     bullet:play3DSound("destroyer_laserfire.wav",0):destroy()
  162.     local light = bullet:addSimpleEffect(ENET_EFFECT_LIGHT_REDLASERBOLTFLY)
  163.     local track = bullet:addSimpleEffect(ENET_EFFECT_PS_REDLASERBOLT)
  164.     waitDeath(bullet:addMoveEffect(ENET_EFFECT_MOVE_LINEARFLY,400,uniGetTarget()),1000)
  165.     light:destroy()
  166.     track:destroy()
  167.     local hit_ps = bullet:addSimpleEffect(ENET_EFFECT_PS_REDLASERBOLTHIT)
  168.     pause(0.2)
  169.     hit_ps:suspendedDestroy(1.0)
  170.     uniGetTarget():executeCommand(ENC_DAMAGED)
  171.     pause(1.0)
  172.     bullet:destroy()
  173. end
  174.  
  175. registerCommand(ENSCRIPTSET_BULLET_REDLASERBOLT,ENC_FIRE1,"bullets_redlaserbolt_fire")
  176.